<template>
  <div>
    <el-container>
      <el-header>
        <div class="user">
          卡号:{{ catNo }}
          <el-button type="text" class="router_link" @click="exit()"
            >退出登录</el-button
          >
          <el-dialog
            title="提示"
            :visible.sync="dialogVisible"
            width="30%"
            :before-close="handleClose"
          >
            <span>这是一段信息</span>
            <span slot="footer" class="dialog-footer">
              <el-button @click="dialogVisible = false">取 消</el-button>
              <el-button type="primary" @click="dialogVisible = false"
                >确 定</el-button
              >
            </span>
          </el-dialog>
        </div>
        <h1>在线银行</h1>
      </el-header>
      <el-container>
        <el-aside width="isCollapse?'60px':'200px'">
          <!-- 折叠的div -->
          <div class="collapse" @click="doCollapse">| | |</div>
          <!-- 侧边栏 -->
          <el-menu
            :collapse="isCollapse"
            :router="true"
            :collapse-transition="false"
            unique-opened
            @open="handleOpen"
            @close="handleClose"
            background-color="#272c33"
            text-color="#fff"
            active-text-color="#ffd04b"
          >
            <NavMenu></NavMenu>
          </el-menu>
        </el-aside>
        <el-container>
          <el-main>
            <router-view></router-view>
          </el-main>
        </el-container>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import NavMenu from "../../components/navmenu/index.vue";
export default {
  data() {
    return {
      catNo: localStorage.getItem("cardNo"),
      isCollapse: false,
      dialogVisible: false,
    };
  },
  components: {
    NavMenu,
  },

  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    doCollapse() {
      this.isCollapse = !this.isCollapse;
    },
    exit() {
      this.$confirm("确认退出？")
        .then((_) => {
          localStorage.removeItem("catNo");
          this.$router.push({
            name: "login",
          });
        })
        .catch((_) => {});
      //
    },
  },
};
</script>

<style lang="less" scoped>
.user {
  width: 50%;
}
.el-header {
  display: flex;
  background-color: #272c33;
  padding: 0 20px;
  color: #e9eef3;
}

.el-aside {
  background-color: #272c33;
  width: 190px;
  .collapse {
    background-color: #272c33;
    text-align: center;
    font-size: 26px;
    height: 50px;
    line-height: 30px;
    letter-spacing: 0.2em;
  }
  height: 600px;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
  line-height: 50px;
  height: 600px;
}

body > .el-container {
  margin-bottom: 40px;
}

.router_link {
  color: #fff;
}
a {
  color: #409eff;
  text-decoration: none;
}
</style>